const VSHADER_SOURCE = `
    attribute vec4 a_Position;
    void main(){
      gl_Position = a_Position;
      gl_PointSize=4.0;
    }`;

const FSHADER_SOURCE = `
    precision mediump float;
    uniform vec4 u_FragColor;
    void main(){
      gl_FragColor = u_FragColor;
    }`;

const canvas = document.getElementById('canvas');

const gl = getWebGLContext(canvas);

initShaders(gl, VSHADER_SOURCE, FSHADER_SOURCE);

let a_Position = gl.getAttribLocation(gl.program, 'a_Position');
let u_FragColor = gl.getUniformLocation(gl.program, 'u_FragColor');


gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0.5, 0.5, -0.5, 0.5, 0, 0]), gl.STATIC_DRAW);
gl.vertexAttribPointer(a_Position, 2, gl.FLOAT, false, 0, 0);
gl.enableVertexAttribArray(a_Position);
gl.clearColor(0.0, 0.0, 0.0, 1.0);
gl.clear(gl.COLOR_BUFFER_BIT);
gl.uniform4f(u_FragColor, ...[0.0, 1.0, 0.0, 1.0]);
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 3);

const ctx = canvas.getContext('2d');
ctx.rect(20, 20, 150, 100);
ctx.fillStyle = "green";
ctx.fill();